package com.qly.protobuf.service.web;

import com.qly.protobuf.service.protobuf.MessageUserLogin;
import org.springframework.web.bind.annotation.*;

import java.util.UUID;

/**
 * Created by Andy ye on 2019/4/24.
 */
@RestController
public class IndexController {

    @GetMapping(value = "/hi")
    public String hi(@RequestParam String name) {
        return "hi: " + name;
    }


    @RequestMapping(value = "/user_proto", produces = "application/x-protobuf")
    @ResponseBody
    public MessageUserLogin.MessageUserLoginResponse getPersonProto(@RequestBody MessageUserLogin.MessageUserLoginRequest request) {
        MessageUserLogin.MessageUserLoginResponse.Builder builder =
                MessageUserLogin.MessageUserLoginResponse.newBuilder();
        builder.setAccessToken(UUID.randomUUID().toString());
        builder.setUsername(request.getUsername());
        return builder.build();
    }
}
